import requests
import json

# 测试加法API (带Bearer Token)
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer my-secret-token"
}

response = requests.post(
    "http://192.168.0.4:5000/add",
    json={"a": 5, "b": 3},
    headers=headers
)

print(f"状态码: {response.status_code}")
print(f"结果: {response.json()}")

# 测试无Token的情况
print("\n测试无Token:")
response2 = requests.post(
    "http://192.168.0.4:5000/add",
    json={"a": 5, "b": 3}
)
print(f"状态码: {response2.status_code}")
print(f"结果: {response2.json()}")

# 测试错误Token格式
print("\n测试错误Token格式:")
headers3 = {
    "Content-Type": "application/json",
    "Authorization": "wrong-format-token"
}
response3 = requests.post(
    "http://192.168.0.4:5000/add",
    json={"a": 5, "b": 3},
    headers=headers3
)
print(f"状态码: {response3.status_code}")
print(f"结果: {response3.json()}")